package com.go.dp.observer.one;

class Child {
	private boolean wakenUp = false;

	public boolean isWakenUp() {
		return wakenUp;
	}

	public void setWakenUp(boolean wakenUp) {
		this.wakenUp = wakenUp;
	}

	public void wakeUp() {
		this.wakenUp = true;
	}

}

class Dad implements Runnable {
	private Child child;

	public Dad(Child child) {
		this.child = child;
	}

	@Override
	public void run() {
		int count = 0;
		while (!child.isWakenUp()) {
			try {
				Thread.sleep(1000);
				System.out.println(count++);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}

		feed();
	}

	public void feed() {
		System.out.println("feed child!");
	}

}

public class MyClass {
	public static void main(String[] args) {
		Child child = new Child();
		new Thread(new Dad(child)).start();
	}
}
